package com.huawei.codearts.controller;

import com.huawei.codearts.service.MessageConsumer;
import com.huawei.codearts.tools.utils.ResponseUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


@Slf4j
@RestController
@RequestMapping(value = "message")
public class MessageSender {

    @Autowired
    private MessageConsumer messageConsumer;

    @RequestMapping(value = "/send")
    public String sendMessage(@RequestParam Map<String, Object> params) {
        String message = (String)params.get("message");
        return ResponseUtils.response(messageConsumer.sendMessage(message));
    }

    @RequestMapping(value = "/delay/send")
    public String delaySendMessage(@RequestParam Map<String, Object> params) {
        String message = (String)params.get("message");
        return ResponseUtils.response(messageConsumer.delaySendMessage(message));
    }

}
